package com.xue.zuoye0214;

import java.text.MessageFormat;

public class Company {
    //成员变量
    private int caculateMonth;//打印的工资月份
    private ColaEmployee colaEmployee;//打印的员工

    //行为方法
    /**
     * 打印员工工资
     */
    public void printEmployeeSalary(){
        /*System.out.println(caculateMonth+"月份工资：姓名："
                              + colaEmployee.getName()+",工资金额："
                              + colaEmployee.getSalary(caculateMonth));
    }*/
        // 带占位符的格式
        String strFormat = "{0}月份工资：姓名：{1},工资金额：{2}";
        // 占位符需要替换的参数数组（以数组的形式或变长参数的形式提供可以替换的参数）
        String strMessage = MessageFormat.format(strFormat,
                caculateMonth,colaEmployee.getName(),
                colaEmployee.getSalary(caculateMonth));
        System.out.println(strMessage);
    }


    //构造方法
    public Company(int caculateMonth, ColaEmployee colaEmployee) {
        this.caculateMonth = caculateMonth;
        this.colaEmployee = colaEmployee;
    }
    //显示写出 默认的构造方法
    public Company() {
    }

    // 私有的属性提供Getter和Setter方法
    public int getCaculateMonth() {
        return caculateMonth;
    }

    public void setCaculateMonth(int caculateMonth) {
        this.caculateMonth = caculateMonth;
    }

    public ColaEmployee getColaEmployee() {
        return colaEmployee;
    }

    public void setColaEmployee(ColaEmployee colaEmployee) {
        this.colaEmployee = colaEmployee;
    }
}
